package utils;

import gui.view.MultiLineHeaderRenderer;

import java.awt.Dimension;

import javax.swing.JTable;
import javax.swing.table.TableColumn;

/**
 * 
 * @author D'Er'Nasherbrezon aka dernasherbrezon %)
 *
 */
public class SimpleColumn extends TableColumn
{
	protected boolean isVisible = true;
	protected boolean isFreeze = false;
	public ColumnGroup parent = null;
	
	public int realModelIndex = 0;
	
	public SimpleColumn()
	{
	}
	
	public SimpleColumn(int modelIndex,Object text)
	{
		realModelIndex = modelIndex;
		setHeaderValue(text);
		setHeaderRenderer(new MultiLineHeaderRenderer());
	}
	
    public Dimension getSize(JTable table)
    {
    	return new Dimension(getWidth(),0);
    }
    
    public void setColumnMargin(int margin)
    {
    }
    
    @Override
    public String toString()
    {
    	return getHeaderValue().toString();
    }
    
    public void setVisible(boolean isVisible)
    {
    	this.isVisible = isVisible;
    	if(parent!=null)
    	{
    		parent.setVisible(isVisible);
    	}
    }
    
    public boolean isVisible()
    {
    	return isVisible;
    }
    
    public void setFreeze(boolean isFreeze)
    {
    	this.isFreeze = isFreeze;
    	if(parent!=null)
    	{
    		parent.setFreeze(isFreeze);
    	}
    }
    
    public boolean isFreeze()
    {
    	return isFreeze;
    }
}
